<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分类页</title>
    <link rel="stylesheet" href="./css/style.css">
</head>

<body>
    <div class="fix-title">
        <span>分类</span>
        <div class="text"><a href="search.html">搜索</a></div>
    </div>
    <ul class="cate-list">
        <!-- <li><a href="list.html">分类1</a></li>
        <li><a href="list.html">分类2</a></li>
        <li><a href="list.html">分类3</a></li>
        <li><a href="list.html">分类4</a></li>
        <li><a href="list.html">分类5</a></li> -->
    </ul>

    <script src="./js/jquery.js"></script>
    <script>
        $.ajax({
            method: 'GET',
            url: 'http://124.223.14.236:3001/api/goods/cate',
            success(res) {
                res.data.map(function (index, item) {
                    const newLi = `<li><a href="list.html" id=${index.id}>${index.name}</a></li>`
                    // console.log(index.name);
                    $('.cate-list').append(newLi)
                })
            }
        })

        $('.cate-list').on('click', function (e) {
            // e.preventDefault()
            if (e.target.tagName === 'A') {
                console.log(e.target.id);
                localStorage.setItem('ID', e.target.id)
            }
        })
    </script>

    <!-- <script>
        $.ajax({
            method: 'GET',
            url: 'http://124.223.14.236:3001/api/goods/cate',
            success(res) {
                console.log(res);
                res.data.map(function (index, item) {
                    const newLi = `<li><a href="list.html" id=${index.id}>${index.name}</a></li>`
                    $('.cate-list').append(newLi)
                })
            }
        })
    </script> -->
</body>

</html>